package org.singledog.form.builder.parser.freemarker.view;

import com.alibaba.fastjson.JSONObject;
import org.singledog.form.builder.ComponentType;
import org.singledog.form.builder.MagicConstants;

import java.util.Map;

public class DialogView extends AbstractFreemarkerView {
    public DialogView(String viewCode, JSONObject schema) {
        super(viewCode, schema);
    }

    @Override
    public ComponentType viewType() {
        return ComponentType.dialog;
    }

    @Override
    protected Map<String, Object> processTemplateData(Map<String, Object> viewData, boolean readonly) {
        viewData = super.processTemplateData(viewData, readonly);
        viewData.put(MagicConstants.VIEW_CODE, getViewCode());
        viewData.put(MagicConstants.DATASET_RET, invokeDataSets(this.getSchema()));
        viewData.putAll(schema);
        return viewData;
    }
}
